﻿/*
*┌────────────────────────────────────────────────┐
*│　描    述：DictionaryBLL                                                   
*│　作    者： (Jxw)                                             
*│　版    本：1.0                                              
*│　创建时间：2020/8/21 14:04:15                        
*└────────────────────────────────────────────────┘
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Utility;

namespace BLL
{
    public class DictionaryBLL
    {
        public RetInfo<List<Hashtable>> GetDictionaryList()
        {
            RetInfo<List<Hashtable>> ri = new RetInfo<List<Hashtable>>(true);
            try
            {
                LogUtility.Debug("GetDictionaryList", DateTime.Now.ToString());
                StringBuilder sb = new StringBuilder(@"
select * from [dbo].[TZDictionary] t
where t.是否有效=1
order by t.顺序号");
                DataSet ds = DataSetUtility.GetDataSetFromCDB(sb);
                List<Hashtable> list = new List<Hashtable>();
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    Hashtable ht;
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        ht = new Hashtable();
                        ht.Add("id", dr["编码"]);
                        ht.Add("name", dr["名称"]);
                        ht.Add("typeID", dr["类型编码"]);
                        ht.Add("order", dr["顺序号"]);
                        list.Add(ht);
                    }
                }
                if (list.Count > 0)
                {
                    ri.data = list;
                }
                else
                {
                    ri.ret = false;
                    ri.res = "未获取到字典数据";
                }
            }
            catch (Exception ex)
            {
                LogUtility.Error("DictionaryBLL/GetDictionaryList", ex.ToString());
                ri.ret = false;
                ri.res = ex.Message;
            }
            return ri;
        }
    }
}
